<template>
  <div class=" tab-bar-item" @click="tabBarItemChanged">
    <div v-if="!isActive">
      <slot name="icon-nor"></slot>
    </div>
    <div v-else>
      <slot name="icon-sel"></slot>
    </div>
    <div :class="{ active: isActive }">
      <slot name="title"></slot>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    path: String
  },
  data() {
    return {};
  },
  computed: {
    isActive() {
      return this.$route.path.indexOf(this.path) !== -1;
    }
  },
  methods: {
    tabBarItemChanged() {
      if (this.isActive) return;

      this.$router.replace(this.path);
    }
  }
};
</script>

<style scoped>
.tab-bar-item {
  flex: 1;
  text-align: center;
  font-size: 13px;
  color: #686464;
  height: 49px;
}

.tab-bar-item img {
  vertical-align: middle;
  width: 23px;
  height: 24px;
  margin-top: 3px;
  margin-bottom: 2px;
}

.active {
  color: #467ed8;
}
</style>
